#ifndef __PA_JST__H__
#define __PA_JST__H__

#include <stdint.h>
#include "pacmn.h"

#ifdef __cplusplus
extern "C"{
#endif

#define JST_RSP_FLAG_OK                          0x00
#define JST_RSP_FLAG_ERR_CRC                     0x01
#define JST_RSP_FLAG_ERR_CMD_NUM                 0x02
#define JST_RSP_FLAG_ERR_CMD_DATA                0x03
#define JST_RSP_FLAG_ERR_PROC                    0x04

#define JST_MOD_ADDR_FUNC_PA                     0x08
#define JST_MOD_ADDR_FUNC_LNA                    0x09
#define JST_MOD_ADDR_FUNC_LPA                    0x0E

#define JST_MOD_ADDR_DL                          0
#define JST_MOD_ADDR_UL                          1

#define JST_CMD_SET_MOD_ADDR                     0x10
#define JST_CMD_GET_MOD_STATUS                   0x11
#define JST_CMD_GET_MOD_SWVER                    0x12
#define JST_CMD_SET_ATT                          0x20
#define JST_CMD_SET_SWITCH                       0x22
#define JST_CMD_SET_ALC                          0x23
#define JST_CMD_ADJUST_GAIN                      0x44
#define JST_CMD_SET_GAIN                         0x45
#define JST_CMD_RESET                            0x88

#define JST_CMD_OFFSET_HEAD_FLAG                 0x00
#define JST_CMD_OFFSET_MOD_ADDR                  0x01
#define JST_CMD_OFFSET_MOD_ADDR_FUNC             0x01
#define JST_CMD_OFFSET_MOD_ADDR_CODE             0x02
#define JST_CMD_OFFSET_CMD_CODE                  0x03
#define JST_CMD_OFFSET_RSP_FLAG                  0x04
#define JST_CMD_OFFSET_CMD_SIZE                  0x05
#define JST_CMD_OFFSET_CMD_DATA                  0x06

#define JST_LPA_POWER_OFF                        0x0
#define JST_LPA_POWER_ON                         0x1

typedef struct tag_jst_lpa_status {
    uint8_t state;
    int8_t lna_att;
    int8_t gain;
    int8_t lna_power;
    int8_t lna_alc;
    int8_t pa_rpower;
    int8_t pa_temp;
    int8_t pa_alc;
    int8_t pa_swratio;
    int8_t pa_att;
    int8_t pa_opower;
    int8_t pa_ipower;
    int8_t pa_spower;
} jst_lpa_status;

pa_ret_t jst_get_lpa_status(int32_t com_fd, mod_addr_t *lpa_addr, jst_lpa_status *lpa_status);

pa_ret_t jst_get_lpa_sw_ver(int32_t com_fd, mod_addr_t *lpa_addr);

pa_ret_t jst_set_lpa_addr(int32_t com_fd, mod_addr_t *lpa_addr, uint8_t new_addr);

pa_ret_t jst_set_lpa_switch(int32_t com_fd, mod_addr_t *lpa_addr, int8_t on_off);

pa_ret_t jst_set_lpa_att(int32_t com_fd, mod_addr_t *lpa_addr, int8_t ul_att, int8_t dl_att);

pa_ret_t jst_set_lpa_reset(int32_t com_fd, mod_addr_t *lpa_addr);


#ifdef __cplusplus
}
#endif

#endif //__PA_JST__H__
